package com.guigu.www.erp.dehao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.pojo.MApply;
import com.guigu.www.erp.common.pojo.PageVo;
import com.guigu.www.erp.dehao.dao.MApplyMapper;
import com.guigu.www.erp.dehao.service.DHMApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DHMApplyServiceImpl implements DHMApplyService {
    @Autowired
    private MApplyMapper mapper;

    @Override
    public void deleteByPrimaryKey(Integer id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insertSelective(MApply mApply) {
        mapper.insertSelective(mApply);
    }

    @Override
    public MApply selectByPrimaryKey(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateByPrimaryKeySelective(MApply mApply) {
        mapper.updateByPrimaryKeySelective(mApply);
    }

    @Override
    public PageVo<MApply> findLikeMApply(Integer pageNum,Integer pageSize,
                                         String productName, String startTime, String endTime
                                                        ,Integer dept_id) {
        PageHelper.startPage(pageNum,pageSize);
        List<MApply> likeMApply = mapper.findLikeMApply("%"+productName+"%", startTime, endTime,dept_id);
        PageInfo<MApply> info =new PageInfo<>(likeMApply);

        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public PageVo<MApply> queryLikeMApply(Integer pageNum, Integer pageSize, String applyId, String productName, String startTime, String endTime) {
        PageHelper.startPage(pageNum,pageSize);
        List<MApply> likeMApply = mapper.queryLikeMApply
                ("%"+applyId+"%","%"+productName+"%", startTime, endTime);
        PageInfo<MApply> info =new PageInfo<>(likeMApply);

        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public String queryMaxApplyId() {
        return mapper.queryMaxApplyId();
    }

    @Override
    public List<MApply> queryByApplyId(String applyId) {
        return mapper.queryByApplyId(applyId);
    }

    @Override
    public void updateByApplyId(MApply mApply) {
        mapper.updateByApplyId(mApply);
    }

    @Override
    public Integer numberCheckTag0() {
        return mapper.numberCheckTag0();
    }

    @Override
    public Integer numberCheckTag1() {
        return mapper.numberCheckTag1();
    }

    @Override
    public Integer numberCheckTag2() {
        return mapper.numberCheckTag2();
    }
}
